package com.example.bindservice;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import androidx.annotation.Nullable;
public class MyService extends Service {
    private static final String TAG = "MyService";
    //创建服务的代理，调用服务中的方法
    class MyBinder extends Binder{
        public void callMethodInService(){
            methodInService();
        }
    }
    private void methodInService() {
        Log.i(TAG, "执行服务中的methethodInService()方法");
    }
    @Override
    public void onCreate() {
        Log.i(TAG, "创建服务，执行onCreate()方法");
        super.onCreate();
    }
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.i(TAG, "绑定服务，执行onBind()方法");
        return new MyBinder();
    }
    @Override
    public boolean onUnbind(Intent intent) {
        Log.i(TAG, "解绑服务，执行onUnbind()方法");
        return super.onUnbind(intent);
    }
}
